<?php
/**
 * 自动加载类
 */
namespace core;
class Loader {

	public static function autoload($name) {
		$basename = basename($name);
		$basename = strtolower($basename);
		// echo $basename;
		// 核心类加载
		if(strpos($name, 'core') === 0) {
			include_once CORE . $basename . '.php';
		}elseif(strpos($name, 'app') === 0) {
			// 加载应用目录类
			$path = substr($name, 4, -strlen($basename));
			$path = str_replace('\\', '/', $path);

			include_once APP_PATH . $path . $basename .  '.php';
		}
	}

	// 注册自动加载
	public static function register() {
	
		spl_autoload_register('core\Loader::autoload');
	}
}